Imports System.Threading

Module SuspendResumeAbort

    Public A As Thread
    Public B As Thread
    Public C As Thread

    Sub DisplayA()
        Try
            A.Suspend()
            For I As Integer= 0 To 100
                Console.Write("A")
            Next
        Catch E As ThreadStateException
            Console.WriteLine(E.Message)
        End Try
    End Sub

    Sub DisplayB()
        Try
            For I As Integer= 0 To 100
                Console.Write("B")
            Next
        Catch E As ThreadAbortException
            Console.Write("Thread B Cham dut")
        End Try

    End Sub

    Sub DisplayC()
        Try
            If (B.IsAlive) Then
                B.Abort()
            End If

            For I As Integer= 0 To 100
                If (A.ThreadState = ThreadState.Suspended)  Then
                    A.Resume()
                End If
                Console.Write("C")
            Next
        Catch E As Threading.ThreadStateException
            Console.WriteLine(E.Message)
        End Try
    End Sub

    Sub Main()

        A = New Thread(AddressOf DisplayA)
        B = New Thread(AddressOf DisplayB)
        C = New Thread(AddressOf DisplayC)

        A.Start()
        B.Start()
        C.Start()

        Console.ReadLine()  
    End Sub

End Module
